package com.thoughtorigin.reflect {
import flash.display.Sprite;
import flash.utils.Dictionary;
import flash.utils.describeType;

import flash.utils.getQualifiedClassName;

import org.flexunit.asserts.assertEquals;

public class DescribeTest {

    private var compare: XML;
    private var _cache: Dictionary;

    [Before]
    public function setUp(): void {
        compare = describeType(Sprite);
        _cache = new Dictionary();
    }

    [Test]
    public function testShouldDescribeClass(): void {
        var source: XML = Describe.type(Sprite);
        assertEquals(compare, source);
    }

    [Test]
    public function testShouldDescribeObjectAndCacheResults(): void {
        Describe.cache = _cache;
        var key: String = getQualifiedClassName(Sprite);
        var source: XML = Describe.type(Sprite);

        assertEquals(source, _cache[key]);
    }

    [Test]
    public function testShouldDescribeOnlyOnceAndAlwaysReturnCache(): void {
        //todo: not fully tested
        Describe.cache = _cache;
        var key: String = getQualifiedClassName(Sprite);
        var source: XML = Describe.type(Sprite);

        assertEquals(source, _cache[key]);

    }
}
}